
<?php
	//=========================<script réaliser par :BOUFTIH Fadwa>===================
	

	//=========================<script réaliser par :Bouftih Fadwa>===================
	//include_once("verif_session.php");
	include_once("bdd_connection.php");
	

	include_once("verif_session.php");
	include_once("bdd_connection.php");

	include_once('config.php');   
	include_once('Connect_pdo.php');
	require_once("dao/planningDao.php");
	require_once("dao/tacheDao.php");
    require_once("dao/nomadeDao.php");

    

   	extract($_GET);
    extract($_POST);
    $msg=0;
	
	

		$planningDao=new planningDao();
		$tacheDao=new tacheDao();
		$listePlan=$planningDao->loadAllTachePlannifiee();
		$nomadedao=new nomadeDao();
		$listeNomade=$nomadedao->loadAllNomade();


		$planning= new planningBean();

  if(isset($ordrePriorite)and isset($designation) and isset($dateDebut)and isset($objectif) and isset($nomade) and isset($dateFin)){

	$planning->setOrdrePriorite($ordrePriorite);
	//$planning->setIdTache($idtache);
	$planning->setIdAdministrateur(10);
	$planning->setDateFin($dateFin);
    $planning->setDateDebut($dateDebut);
    $planning->setObjectif($objectif);
    $planning->setDesignation($designation);
	$planning->setIdNomade($nomade);
	}
	
	if(isset($ajout))
	{
	    $tacheDao->insertTache($planning);
	    $idtache=$tacheDao->loadIdTache($designation,$objectif);
	    $tacheDao->insertNomadeTache($idtache,$planning->getIdNomade());
        $planning->setIdTache($idtache);     
	    $planningDao->insertPlanning($planning);
	    $message="Ajout effectué!";
	    $msg=1;

       // $tpl->assign("message",$message);
	}


	if(isset($id))
	{

		$planning->setIdTachePlanifier($id);
	    $tacheDao->insertTache($planning);
	    $idtache=$tacheDao->loadIdTache($designation,$objectif);
	    $tacheDao->insertNomadeTache($idtache,$planning->getIdNomade());
        $planning->setIdTache($idtache);     
	    $planningDao->insertPlanning($planning);
	    deletePlanning($planning);
	   $message="Modification effectueé avec succes!";
	    $msg=2;
	   
	}
	
	if(isset($id_sup))
	{
	   $planning->setIdTachePlanifier($id_sup);
	   $planningDao->deletePlanning($planning);
	   $message="Suppression effectueé avec succes!";
	    $msg=3;
	   
	}
	


            
           
          
           if(($msg==1) or ($msg==2) or ($msg==3)){
				$tpl->assign("message",$message);	
				}
			
			if(isset($listePlan))		
			$tpl->assign("listePlanning", $listePlan);
		    $tpl->assign("listeNomade", $listeNomade);
			$tpl->assign("nomadedao", $nomadedao);
			$tpl->display("planning.html");
			   

				

?>








<!--


	if(isset($ajout))
	{
	   mysql_query (" INSERT INTO tache VALUES('$id','$objectif','$designation','$datedebut')");
	   $message="Ajout effectué!";
	   $tpl->assign("message",$message);
  
       mysql_close();
	}


	if(isset($id))
	{
	   mysql_query (" UPDATE tache set nom='$nom', type='$type', description='$description' where idTache=$id");
	   $message="Modification effectueé avec succes!";
	   $tpl->assign("message",$message);
  
       mysql_close();
	}
	

	if(isset($id_sup))
	{
	   mysql_query (" DELETE FROM tache where idTache=$id_sup");
	   $message="Suppression effectueé avec succes!";
	   $tpl->assign("message",$message);
  
       mysql_close();
	}

$query = $con->prepare("select * from tache");
		if($query->execute()){
			$count = $query->rowCount();
			$query->setFetchMode(PDO::FETCH_OBJ);
			if($count > 0){
				while($line = $query->fetch()){
					$return[] = array(
								"ID"=> $line->idTache,
								"objectif"=> $line->objectif,
								"designation"=> $line->designation,
								"dateDebut"=> $line->dateDebut
								
								
								
								);
				}  
				
				$tpl->assign("return", $return);
				$tpl->display("planning.html");
			
	}
	}
	?> */

-->



	
